'use strict';
module.exports = app => {
  const { INTEGER, STRING } = app.Sequelize;
  const Exam = app.model.define(
    'Exam',
    {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      count: INTEGER(11),
      teacher_id: INTEGER(11),
        course_id: INTEGER(11),
        address: STRING(255),
    },
    {
      tableName: 'exam',
      timestamps: true, // 启用时间戳(createdAt, updatedAt)
      updatedAt: false, // 不想要 updatedAt
      createdAt: 'created_at', // 想要  createdAt 但是希望名称叫做 created_at
    }
  );

    Exam.associate = () => {
        const { Teacher, Course } = app.model;
        Exam.hasOne(Teacher, {foreignKey: 'id', sourceKey: 'teacher_id'})
        Exam.hasOne(Course, {foreignKey: 'id', sourceKey: 'course_id'})
    };

  return Exam;
};
